/**
 * 如果内容里有`__components__: ['button', 'card']` 就转换成 ['button', 'card']
 * 目的是自动引入examples的组件
 */
export function CompsStrToArray(str: string) {
  const match = str.match(/__components__:\s*(\[[^\]]+\])/)
  if (match) {
    try {
      const arrayStr = match[1].replace(/'/g, '"')
      const array = JSON.parse(arrayStr)
      return array as string[]
    }
    catch (_e) {
      return [] as string[]
    }
  }
  return [] as string[]
}
